﻿using System;
using System.Windows;
using System.Windows.Data;

namespace QDP.Platform.Silverlight.Converters
{
    /// <summary>
    /// 布尔值转可见度
    /// </summary>
    public class BoolToVisibilityConverter : IValueConverter
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="value"></param>
        /// <param name="targetType"></param>
        /// <param name="parameter"></param>
        /// <param name="culture"></param>
        /// <returns></returns>
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value != null && value is bool)
            {
                if (parameter == null)
                    return System.Convert.ToBoolean(value) ? Visibility.Visible : Visibility.Collapsed;
                else
                    return System.Convert.ToBoolean(value) ? Visibility.Collapsed : Visibility.Visible;
            }
            if (parameter == null)
                return Visibility.Collapsed;
            else
                return Visibility.Visible;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="value"></param>
        /// <param name="targetType"></param>
        /// <param name="parameter"></param>
        /// <param name="culture"></param>
        /// <returns></returns>
        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}